﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using 多协议通信平台.Enums;

namespace 多协议通信平台.ViewModels.Component
{
    public partial class ProxySetViewModel : ObservableObject
    {
        [ObservableProperty]
        private bool useProxy;

        [ObservableProperty]
        private bool isVisible = false;

        [ObservableProperty]
        private ProxyMode proxyMode;

        [ObservableProperty]
        private ProxyProtocal proxyProtocal;

        public List<EnumNameValue<ProxyMode>> ProxyModes { get; set; }

        public List<EnumNameValue<ProxyProtocal>> ProxyProtocals { get; set; }

        public ProxySetViewModel()
        {
            Init();
        }

        private void Init()
        {
            ProxyModes = new List<EnumNameValue<ProxyMode>>();
            foreach (var val in Enum.GetValues<ProxyMode>())
            {
                string? name = Enum.GetName<ProxyMode>(val);
                ProxyModes.Add(new EnumNameValue<ProxyMode>() { Name = name, Value = val });
            }

            ProxyProtocals = new List<EnumNameValue<ProxyProtocal>>();
            foreach (var val in Enum.GetValues<ProxyProtocal>())
            {
                string? name = Enum.GetName<ProxyProtocal>(val);
                ProxyProtocals.Add(new EnumNameValue<ProxyProtocal>() { Name = name, Value = val });
            }
        }

        [RelayCommand]
        public void ModifyProxy()
        {
            IsVisible = true;
        }
    }
}
